Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP CI including PHPCS and PHPUnit; bump PHP/WP versions #1095

Merged
merged 24 commits into from
Jan 19, 2024

Conversation

westonruter
Copy link
Collaborator

@westonruter westonruter commented Jan 18, 2024

Closes #983
Closes #1056

@westonruter westonruter added this to the 0.8 milestone Jan 18, 2024
@thelovekesh thelovekesh mentioned this pull request Jan 18, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (62961cd) 19.65% compared to head (9fa812d) 29.34%.
Report is 17 commits behind head on develop.

Files Patch % Lines
...ponents/class-wp-service-worker-caching-routes.php 0.00% 4 Missing ⚠️
bin/verify-version-consistency.php 0.00% 2 Missing ⚠️
...ass-wp-service-worker-admin-assets-integration.php 0.00% 2 Missing ⚠️
...ss-wp-service-worker-custom-header-integration.php 0.00% 1 Missing ⚠️
wp-admin/admin.php 0.00% 1 Missing ⚠️
wp-includes/general-template.php 0.00% 1 Missing ⚠️
wp-includes/template.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1095      +/-   ##
=============================================
+ Coverage      19.65%   29.34%   +9.69%     
+ Complexity       347      334      -13     
=============================================
  Files             57       57              
  Lines           2325     1690     -635     
=============================================
+ Hits             457      496      +39     
+ Misses          1868     1194     -674     
Flag Coverage Δ
php 29.34% <20.00%> (+9.69%) ⬆️
unit 29.34% <20.00%> (+9.69%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

},
"platform": {
"php": "5.6"
"php": "7.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to emulate it to 7.0 else it can download deps that don't support PHP 7.0.

Copy link
Collaborator Author

@westonruter westonruter Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm. I had updated the composer.lock file for PHP 8.0 so we'll need to update it for 7.0. However, when I do so then I get errors when running tests locally:

$ npm run test:php

> test:php
> wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/pwa/ env WORDPRESS_TABLE_PREFIX=wptests_ vendor/bin/phpunit

ℹ Starting 'env WORDPRESS_TABLE_PREFIX=wptests_ vendor/bin/phpunit' on the tests-cli container. 

[18-Jan-2024 22:34:19 UTC] PHP Warning:  Private methods cannot be final as they are never overridden by other classes in /var/www/html/wp-content/plugins/pwa/vendor/phpunit/phpunit/src/Util/Configuration.php on line 176
[18-Jan-2024 22:34:19 UTC] PHP Fatal error:  Cannot acquire reference to $GLOBALS in /var/www/html/wp-content/plugins/pwa/vendor/phpunit/phpunit/src/Util/Configuration.php on line 543
✖ Command failed with exit code 255

If I change it to 7.4 and run composer update then I can run PHPUnit successfully, even when I'm running PHP 8.1.

Can we change this then to (and run composer update):

Suggested change
"php": "7.0"
"php": "7.4"

If that means removing tests for PHP 7.0-7.3, I'm fine with that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the PHPUnit version is not compatible with the PHP version inside the container. So I think we need to use updated PHPUnit for local testing.

So we have two options now:

  • We save PHPUnit 9.6 PHAR in bin like we do for PHPStan and keep 7.0 tests.
  • Remove 7.0 tests and bump PHP emulation to 7.1.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now PHPUnit version is customizable in local development with - 9fa812d

With this, we can download any PHPUnit version and keep the tests for PHP 7.0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever!

@westonruter westonruter merged commit 448dad5 into develop Jan 19, 2024
18 checks passed
@westonruter westonruter deleted the fix/php-ci branch January 19, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants